fix: request analyzer stats fields#718
Conversation
🦋 Changeset detectedLatest commit: 11af922 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for forwarding statsOptions from BundleAnalyzerPlugin options into stats.toJson(...), ensuring analyzer/report generation uses the intended webpack stats shape.
Changes:
- Pass
this.opts.statsOptionsintostats.toJson(...)forserver,static, andjsonanalyzer modes. - Add Jest coverage to verify
statsOptionsis forwarded and the chosen analyzer method receives the resulting stats JSON.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/plugin.js | Adds parameterized tests validating statsOptions propagation across analyzer modes. |
| src/BundleAnalyzerPlugin.js | Updates plugin to call stats.toJson(this.opts.statsOptions) when generating analyzer outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
36d30b5 to
bdb4e2f
Compare
bdb4e2f to
8049c31
Compare
valscion
left a comment
There was a problem hiding this comment.
What use case needs this? Never heard of this kind of need in the past
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #718 +/- ##
==========================================
- Coverage 76.30% 76.29% -0.01%
==========================================
Files 17 17
Lines 979 983 +4
Branches 357 357
==========================================
+ Hits 747 750 +3
- Misses 205 206 +1
Partials 27 27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@valscion This is mainly for Rspack 2.0 compatibility. Rspack 2.0 changed the default output of webpack-bundle-analyzer currently calls The goal of this PR is to make the analyzer request the minimum stats shape it depends on, instead of relying on compiler-specific defaults. |
There was a problem hiding this comment.
Hmm OK, thanks for explaining! I do understand this better now.
Now I wonder if there's any way to add reasonable test coverage for this... we don't really support Rspack in the sense of having any guarantees of it working here nor do we want to have CI test against it as it brings additional maintenance burden to verify it doesn't break here.
But this is such a small change and doesn't seem brittle so might as well have it. I'll modify the changeset a bit to describe this stance on Rspack.
Explicitly define `stats.toJson()` options for bundle analysis to support Rspack 2.0 with minimal code changes needed.
Summary
Rspack 2.0 changed the default
stats.toJson()output so fields likemodules,assets,chunks,chunkGroups, andentryPointsare no longer included unless requested explicitly. See the Rspack v2 migration guide.That can leave webpack-bundle-analyzer with incomplete stats when it runs against Rspack 2.0. This PR makes analyzer modes request the stats fields they need directly instead of relying on compiler defaults.
Changes
server,static, andjsonanalyzer modes.statsOptionsscoped to generated stats files.Notes
statsOptionsremains user-controlled because users may intentionally filter fields such as assets or modules. Analyzer report generation needs a stable minimum stats shape, so it uses dedicated internal options.Validation
npm testnpm run lintnpm run build:analyzernpm run lint:types